package io.itit.ecp.admin.provide.action.resp;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.itit.ecp.admin.provide.selected.CarbonSinkSelected;
import io.itit.ecp.admin.provide.selected.EmissionSinkForecastDataSinkTypeSelected;
import io.itit.grass.common.provide.action.resp.BaseResp;
import io.itit.grass.dict.starter.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 *
 * @Author：Roy
 * @Description：碳汇数据响应结果
 * @Date：Create by 2023-12-01 10:45:08
 */
@Data
@ToString
@ApiModel("碳汇数据响应结果")
public class CarbonSinkDataResp extends BaseResp {

    private static final long serialVersionUID = 1L;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("数据时间")
    private Date solidifyDate;

    @ApiModelProperty("项目Id")
    private String sceneProjectId;

    @ApiModelProperty("项目名称")
    private String projectName;

    /* 楼栋Id */
    @ApiModelProperty("楼栋Id")
    private String sceneEdificeId;

    @ApiModelProperty("楼栋名称")
    private String sceneEdificeName;

    /* 楼层Id */
    @ApiModelProperty("楼层Id")
    private String sceneFloorId;

    @ApiModelProperty("楼层名称")
    private String sceneFloorName;

    /* 空间Id */
    @ApiModelProperty("空间Id")
    private String sceneRoomId;

    @ApiModelProperty("空间名称")
    private String sceneRoomName;

    /* 碳汇因子Id */
    @ApiModelProperty("碳汇因子Id")
    private String carbonSinkId;

    @ApiModelProperty("碳汇因子名称")
    private String carbonSinkName;

    @ApiModelProperty("名称类型")
    @Dict(dictCode = CarbonSinkSelected.CODE, isBean = true)
    private String type;

    @ApiModelProperty("碳汇类型(1:园区碳汇,2:外购碳汇)")
    @Dict(dictCode = EmissionSinkForecastDataSinkTypeSelected.CODE, isBean = true)
    private String sinkType;

    @ApiModelProperty("面积(㎡)")
    private BigDecimal area;

    @ApiModelProperty("减碳量(kgCO2)")
    private BigDecimal carbonEmission;

    @ApiModelProperty("减碳量(计算过程)")
    private String carbonEmissionProcess;

    @ApiModelProperty("机构Id")
    private String deptId;


    public String getSolidifyDateString() {
        if (Objects.isNull(this.solidifyDate)) {
            return null;
        }
        return DateUtil.format(this.solidifyDate, "yyyy-MM-dd HH:mm:ss");
    }

    public String getFullSceneRoomName() {
        return StringUtils.defaultIfEmpty(this.sceneEdificeName, "") +
                StringUtils.defaultString(this.sceneFloorName, "") +
                StringUtils.defaultString(this.sceneRoomName, "");
    }


}
